package _maps;
import java.io.FileInputStream;
import java.io.IOException;

public class DesktopMap implements I_Map {
	private FileInputStream input;
	private final int BYTE_TO_INT = 48;
	
	public DesktopMap(int mapName) {
		mapLoad(mapName);
	}

	public DesktopMap()
	{
	}
	
	public int[] mapLoad(int mapName)
	{
		byte[] tempByteArr = null;
		
		try {
			input = new FileInputStream("src\\_maps\\" + mapName + ".txt");
			tempByteArr = new byte[input.available()];
			input.read(tempByteArr);
			input.close();
		} catch (IOException e) {}

		for (int i = 0, k = 0; i < tempByteArr.length; i++)
			if (tempByteArr[i] - BYTE_TO_INT >= MAP_EMPTY_SYMBOL && tempByteArr[i] - BYTE_TO_INT <= MAP_CHICKEN_SYMBOL)
				intArr[k++] = tempByteArr[i] - BYTE_TO_INT;
		
		return intArr;
	}
	
	public int[] returnArr()
	{
		return intArr;
	}
}